
// INCLUDES ********************************************************************

#include "Color.h"



static const uint8_t gMaxColorValue = 255;

// NAMESPACES ******************************************************************

using namespace Meteor;

// *****************************************************************************

// -----------------------------------------------------------------------------

Color::Color( const float r, const float g, const float b, const float a) 
: mRed( r), mGreen( g), mBlue( b), mAlpha( a)
{
}

// -----------------------------------------------------------------------------

Color::~Color()
{
}

// -----------------------------------------------------------------------------

Color::Color( const Color& rhs)
{
    mRed = rhs.Red();
    
    mGreen = rhs.Green();
    
    mBlue = rhs.Blue();
    
    mAlpha = rhs.Alpha();
}

// -----------------------------------------------------------------------------

Color& Color::operator=( const Color &rhs)
{
    if ( this == &rhs)
    {
        return *this;
    }
    
    mRed = rhs.Red();
    
    mGreen = rhs.Green();
    
    mBlue = rhs.Blue();
    
    mAlpha = rhs.Alpha();
    
    return *this;
}


// -----------------------------------------------------------------------------

void Color::SetRed( const float value)
{
    mRed = value;
    
    if ( mRed > 1.0f)
    {
        mRed = 1.0f;
    }
}

// -----------------------------------------------------------------------------

void Color::SetRed( const uint8_t value)
{
    const float newValue = value/gMaxColorValue;
    
    SetRed( newValue);
}

// -----------------------------------------------------------------------------

void Color::SetGreen( const float value)
{
    mGreen = value;
    
    if ( mGreen > 1.0f)
    {
        mGreen = 1.0f;
    }
}

// -----------------------------------------------------------------------------

void Color::SetGreen( const uint8_t value)
{
    const float newValue = value/gMaxColorValue;
    
    SetGreen( newValue);
}

// -----------------------------------------------------------------------------

void Color::SetBlue( const float value)
{
    mBlue = value;
    
    if ( mBlue > 1.0f)
    {
        mBlue = 1.0f;
    }
}

// -----------------------------------------------------------------------------

void Color::SetBlue( const uint8_t value)
{
    const float newValue = value/gMaxColorValue;
    
    SetBlue( newValue);
}

// -----------------------------------------------------------------------------

void Color::SetAlpha( const float value)
{
    mAlpha = value;
    
    if ( mAlpha > 1.0f)
    {
        mAlpha = 1.0f;
    }
}

// -----------------------------------------------------------------------------

void Color::SetAlpha( const uint8_t value)
{
    const float newValue = value/gMaxColorValue;
    
    SetAlpha( newValue);
}

// -----------------------------------------------------------------------------

const float Color::Red() const
{
    return mRed;
}

// -----------------------------------------------------------------------------

const float Color::Green() const
{
    return mGreen;
}

// -----------------------------------------------------------------------------

const float Color::Blue() const
{
    return mBlue;
}

// -----------------------------------------------------------------------------

const float Color::Alpha() const
{
    return mAlpha;
}

